#include "SafeQue.h"

using namespace std;

CSafeQueue<int> q;

void* Cons(void* arg)
{
    pthread_detach(pthread_self());
    int t = 0;
    while(t <= 10){
        int x;
        q.Pop(x);
    }
}

void* Pro(void* arg)
{
    pthread_detach(pthread_self());
    int t = 10;
    while(t >= 0){
        cout<<t<<endl;
        q.Push(t--);
    }
}

int main()
{
    pthread_t id;
    for(int i = 0; i < 2; ++i){
        pthread_create(&id, NULL, Cons, NULL);
        pthread_create(&id, NULL, Pro, NULL);
    }
    while(1)
    {
        sleep(1);
    }
    return 0;
}